package leetcode

import "math"

/*
 * @lc app=leetcode.cn id=122 lang=golang
 *
 * [122] 买卖股票的最佳时机 II
 */

// @lc code=start
func maxProfit2(prices []int) int {
	pre := math.MaxInt64
	ret := 0
	for _, v := range prices {
		if v > pre {
			ret += v - pre
		}
		pre = v
	}
	return ret
}

// @lc code=end
